import { createApp } from 'vue'
import App from './App.vue'
import router from './router'

import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import 'element-plus/dist/index.css'
import http from './common/http.js'
import api from './common/api.js'

console.log(http)

const app = createApp(App)

app.provide('httpUrl', process.env.VUE_APP_URL)  // 请求ip或域名
app.provide('httpApi', api) // 请求接口

app.provide('postApi',(path,data) => {
	// post请求方法
	let sj ={
		url: process.env.VUE_APP_URL + path,
		data: data,
		failZt: null
	}
	return new Promise(resolve => {
		http.post(sj).then((res)=>{
			resolve(res)
		})
	})
})
app.provide('getApi',(path) => {
	// get请求方法
	let sj ={
		url: process.env.VUE_APP_URL + path,
		data: {},
		failZt: null
	}
	return new Promise(resolve => {
		http.post(sj).then((res)=>{
			resolve(res)
		})
	})
})

app.use(router).use(ElementPlus,{locale: zhCn}).mount('#app')
